--- <action itemid="2557" event="script" value="carpenter hammer.lua"/>
--- Carpenter hammer maked by Kronos aka Hellboy ---

local non_count_item_table = { -- 
	[5892] = {newId = 11396, newType = 0, needStack = false, trashChance = 0} --- vial
}

local craftable_table = {
	[5901] = { --- wood_table
	--- [itemEx.type] = {newId, newType, needStack, trashChance, trashId}
		[1] = {newId = 2382, needStack = false, trashChance = 0, effect = CONST_ME_BLOCKHIT}, --- club
		[5] = {newId = 2070, needStack = false, trashChance = 0, effect = CONST_ME_BLOCKHIT}, --- flute
		[8] = {newId = 2512, newType = 1, trashChance = 0, trashId = 2255, needStack = false, effect = CONST_ME_BLOCKHIT}, --- wooden shield
		[10] = {newId = 1651, newType = 1, trashChance = 0, trashId = 2255, needStack = true, effect = CONST_ME_BLOCKHIT}, --- wooden chair
		[20] = {newId = 1619, newType = 1, trashChance = 0, trashId = 2255, needStack = true, effect = CONST_ME_BLOCKHIT}, --- small table
		[25] = {newId = 1614, newType = 1, trashChance = 0, trashId = 2255, needStack = true, effect = CONST_ME_BLOCKHIT} --- big table
	},
	[5880] = { --- iron ore
		[1] = {newId = 8309, newType = 15, needStack = false, effect = CONST_ME_BLOCKHIT} --- nails
	}
}

local recipeTable_ = {
	{newId = 1666, components = {[5901] = 15, [5911] = 10}, effect = CONST_ME_BLOCKHIT}, --- 15x wood + 10x red poc
	{newId = 1670, components = {[5901] = 15, [5910] = 10}, effect = CONST_ME_BLOCKHIT}, --- 15x wood + 10x green poc
	
	{newId = 2448, components = {[5901] = 5, [8309] = 15}, effect = CONST_ME_BLOCKHIT} --- 5x wood + 15x nails
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local TABLE
	local tempTable, removeTable = {}, {}
	
	if not recipe(cid, item, fromPosition, itemEx, toPosition, recipeTable_) then
		TABLE = (craftable_table[itemEx.itemid] ~= nil) and (craftable_table[itemEx.itemid])[itemEx.type] or non_count_item_table[itemEx.itemid] or nil
	end
	
	if TABLE ~= nil then
		crafting(cid, item, fromPosition, itemEx, toPosition, TABLE)
	end
	return false
end